package com.example.mobile2021606144ywr0407homework;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity2 extends AppCompatActivity {

    private TextView tvMainTitle1;
    private TextView tvMain11;
    private TextView tvMain12;
    private TextView tvMain13;
    private EditText editMain11;
    private EditText editMain12;
    private TextView tvMain14;
    private Button btnMain1End;
    private  TextView txt;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initView();
        btnMain1End.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String string = editMain11.getText().toString();
                String string2 = editMain12.getText().toString();
                int num1=Integer.valueOf(string).intValue();
                int num2=Integer.valueOf(string2).intValue();
                num1=num1+num2;
                string=String.valueOf(num1);
                txt.setText(string);
            }
        });
    }

    private void initView() {
        tvMainTitle1 = (TextView) findViewById(R.id.tv_main_title1);
        tvMain11 = (TextView) findViewById(R.id.tv_main1_1);
        tvMain12 = (TextView) findViewById(R.id.tv_main1_2);
        tvMain13 = (TextView) findViewById(R.id.tv_main1_3);
        editMain11 = (EditText) findViewById(R.id.edit_main1_1);
        editMain12 = (EditText) findViewById(R.id.edit_main1_2);
        tvMain14 = (TextView) findViewById(R.id.tv_main1_4);
        btnMain1End = (Button) findViewById(R.id.btn_main1_end);
        txt=(TextView)findViewById(R.id.txt);
    }
}